#include <bits/stdc++.h>
using namespace std;
int n;

int getone(int u) {
    int sum = 0;
    while (u > 0) {
        if (u % 10 == 1)
            sum++;
        u /= 10;
    }
    return sum;
}

int main() {
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += getone(i);
    }
    cout << sum;
    return 0;
}